Derivation of a Fast Integer Square Root Algorithm

نویسنده

  • Christoph Kreitz
چکیده

In a constructive setting, the formula ∀n ∃r r2≤n ∧ n<(r+1) specifies an algorithm for computing the integer square root r of a natural number x. A proof for this formula implicitly contains an integer square root algorithm that mirrors the way in which the formula was proven correct. In this note we describe the formal derivation of several integer square root algorithms within the Nuprl proof development system and show how efficient algorithms can be derived using advanced induction schemes. 1 Deriving a Linear Algorithm The standard approach to proving ∀n ∃r r2≤n ∧ n<(r+1)2 is induction on n, which will lead to the following two proof goals Base Case: prove ∃r r2≤0 ∧ 0<(r+1)2 Induction Step: prove ∃r r2≤n+1 ∧ n+1<(r+1)2 assuming ∃rn r2≤n ∧ n<(rn+1). The base case can be solved by choosing r = 0 and using standard arithmetical reasoning to prove the resulting proof obligation 02≤0 ∧ 0<(0+1)2. In the induction step, one has to analyze the root rn. If (rn+1)≤n+1, then choosing r = rn+1 will solve the goal. Again, the proof obligation (rn+1)≤n+1 ∧ n+1<((rn+1)+1) can be shown by standard arithmetical reasoning. (rn+1) > n+1, then one has to choose r = rn and prove r2 n≤n+1 ∧ n+1<(rn+1) using standard arithmetical reasoning. Figure 1 shows the trace of a formal proof in the Nuprl system [CAB+86, ACE+00] that uses exactly this line of argument. It initiates the induction by applying the library theorem NatInd ∀P:N→P. (P(0) ∧ (∀i:N+. P(i-1) ⇒ P(i))) ⇒ (∀i:N. P(i)) The base case is solved by assigning 0 to the existentially quantified variable and using Nuprl’s autotactic (trivial standard reasoning) to deal with the remaining proof obligation. In the step case (from i−1 to i) it analyzes the root r for i−1, introduces a case distinction on (r+1)2≤i and then assigns either r or r+1, again using Nuprl’s autotactic on the rest of the proof. Nuprl is capable of extracting an algorithm from the formal proof, which then may be run within Nuprl’s computation environment or be exported to other programming systems. The algorithm is represented in Nuprl’s extended lambda calculus. Depending on the formalization of the existential quantifier there are two kinds of algorithms that may be extracted. In the standard formalization, where ∃ is represented as a (dependent)

برای دانلود متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید

ثبت نام

اگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید

منابع مشابه

Implementation of Integer Square Root

Square root plays a major role in applications like computer graphics, image processing. To increase the performance of computation, many algorithms have been proposed to carry out the computation task in hardware instead of software. One very common and relatively quick method for finding the square root of a number is the Newton-Raphson method which requires extensive use of division to produ...

متن کامل

A Fast Algorithm for Determining the Existence and Value of Integer Roots of N

We show that all perfect odd integer squares not divisible by 3, can be usefully written as √ N = a + 18p, where the constant a is determined by the basic properties of N . The equation can be solved deterministically by an efficient four step algorithm that is solely based on integer arithmetic. There is no required multiplication or division by multiple digit integers, nor does the algorithm ...

متن کامل

SQUARE−ROOT FORM BASED DERIVATION OF A NOVEL NLMS−LIKE ADAPTIVE FILTERING ALGORITHM (WedAmPO1)

Abstract : In this paper we derive a new adaptive filtering algorithm. Starting from a general square−root formulation [1], we introduce a normalization transform to the updating scheme of the block−diagonal adaptive algorithm presented in [1]. This algorithm is efficiently implemented with a low complexity, the resulting algorithm is similar to the NLMS one. Simulations, in the context of mult...

متن کامل

Square Root Algorithm in F q for q ≡ 2 s + 1 ( mod 2 s + 1 ) Namhun Koo ,

We present a square root algorithm in Fq which generalizes Atkins’s square root algorithm [6] for q ≡ 5 (mod 8) and Kong et al.’s algorithm [8] for q ≡ 9 (mod 16). Our algorithm precomputes a primitive 2-th root of unity ξ where s is the largest positive integer satisfying 2|q − 1, and is applicable for the cases when s is small. The proposed algorithm requires one exponentiation for square roo...

متن کامل

Non-Restoring Integer Square Root: A Case Study in Design by Principled Optimization

Theorem proving techniques are particularly well suited for reasoning about arithmetic above the bit level and for relating di erent levels of abstraction. In this paper we show how a non-restoring integer square root algorithm can be transformed to a very e cient hardware implementation. The top level is a Standard ML function that operates on unbounded integers. The bottom level is a structur...

متن کامل

ذخیره در منابع من


  با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید

برای دانلود متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید

ثبت نام

اگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید

عنوان ژورنال:

دوره   شماره 

صفحات  -

تاریخ انتشار 2003